import { Component, OnInit, Input, ChangeDetectionStrategy } from '@angular/core';

@Component({
  selector: 'el-badge',
  templateUrl: './badge.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BadgeComponent implements OnInit {
  @Input('value') model: string | number = '';
  //primary / success / warning / danger / info
  @Input() type: string = '';
  @Input() max: number = 0;
  //隐藏 badge
  @Input() hidden: boolean = false;
  @Input('is-dot') isDot: boolean = false;

  constructor() { }

  ngOnInit(): void {
  }


  makeContent() {
    if (this.isDot)
      return '';
    if(this.max >0 && this.max < Number(this.model)) {
      return this.max + '+';
    }
    return this.model;
  }
}
